import { Req, ReqOptions } from '../../shared/request/request'
import { prefix } from '../../shared/client/axios'

export const GenderSet = [ 'FEMALE', 'MALE', 'SECRET' ] as const
export type GenderType = typeof GenderSet[number]

export const UserStatusSet = [ 'DELETED', 'NORMAL', 'BLOCKED' ] as const
export type UserStatusType = typeof UserStatusSet[number]

export const UserObjectTypeSet = [ 'GLOBAL', 'SITE' ] as const
export type UserObjectType = typeof UserObjectTypeSet[number]

export interface User {
  id: number,
  username: string,
  logName: string,
  position: string,
  phone: string,
  mail: string,
  describe: string,
  password: string,
}

export interface RegisterData {
  cardId: string,
  name: string,
  password: string,
  phone: string
}

export async function reqLogin(req: Req,logname: string, password:string): Promise<any> {
  const data = await req('post', `${prefix}/user/login`,{ data:{ cardId:logname, password:password } })
  return data
}

export async function reqRegister(req: Req, registerData: RegisterData): Promise<any> {
  const data = await req('post', `${prefix}/user/register`, { data: registerData })
  return data
}

export async function reqTest(req: Req): Promise<any> {
  const data = await req('post', `${prefix}/user/test`, { noToken: false })
  return data
}